﻿@using KRM.Core
@{
    ViewBag.Title = "MoveWareHouseAndCarrier";
    Layout = "~/Views/Shared/_PopupLayout.cshtml";
    tblUser user = ViewBag.User;
    var canMove = !user.HasPermission(Permissions.PickStockCanChangeWarehouse) && !user.HasPermission(Permissions.PickStockCanChangeCarrier);
    var canChangeWarehouse = !user.HasPermission(Permissions.PickStockCanChangeWarehouse) ? "disabled=disabled" : "";
    var canChangeCarrier = !user.HasPermission(Permissions.PickStockCanChangeCarrier) ? "disabled=disabled" : "";
}
<script>
    $(document).ready(function() {
        $("#carrierID").change(function() {
            $.ajax({
                url: "/load/movewarehousecarrierchange?carrierid=" + $(this).val(),
                success: function (data) {
                    $("#CarrierServiceID").html("");
                    $.each(data, function (id, option) {
                        $("#CarrierServiceID").append($('<option></option>').val(option.id).html(option.name));
                    });
                }
            });
        });
    })
</script>
<div style="padding: 10px">
    @Html.Partial("Partial/_MessageResult")
    <form action="/load/MoveWareHouseAndCarrier" method="POST">
        <input type="hidden" value="@ViewBag.LoadId" name="loadid"/>
        <fieldset>
            <legend>Move warehouses</legend>
            <div class="row-fluid">
                <div class="span3"></div>
                <div class="span7">
                    @Html.DropDownList("MoveToWarehouseID", null, new { @class = "input-block-level", canChangeWarehouse })
                </div>
            </div>
        </fieldset>
        <fieldset>
            <legend>New carrier service</legend>
            <div class="row-fluid">
                <div class="span3">Carrier</div>
                <div class="span7">
                    @Html.DropDownList("carrierID", null, new { @class = "input-block-level" })
                </div>
            </div>
            <div class="row-fluid">
                <div class="span3">Service</div>
                <div class="span7">
                    @Html.DropDownList("CarrierServiceID", null, new { @class = "input-block-level",canChangeCarrier })
                </div>
            </div>
        </fieldset>
        <div class="border-padding10 text-center">
            <input type="submit" class="btn btn-primary" value="Move" style="width: 90px" @(canMove ? "disabled=disabled" : "") />
        </div>
    </form>
</div>
